﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Text;

namespace HttpUploader5.demoAccess.db
{
	public class xdb_files
	{
		/// <summary>
		/// 返回JSON字符串 [{fid:"0",uid:"1",fileNameLocal:"urlencode()"}]
		/// FilePathLocal进行UrlEncode编码
		/// FilePathRelative进行UrlEncode编码
		/// </summary>
		/// <returns></returns>
		public string ToJson()
		{
			StringBuilder sb = new StringBuilder();
			sb.Append("[{");
			sb.Append("fid:\""); sb.Append(this._fid); sb.Append("\"");
			sb.Append(",uid:\""); sb.Append(this._uid); sb.Append("\"");
			sb.Append(",FileNameLocal:\""); sb.Append(this._filenamelocal); sb.Append("\"");
			sb.Append(",FileNameRemote:\""); sb.Append(this._filenameremote); sb.Append("\"");
			sb.Append(",FilePathLocal:\""); sb.Append(HttpUtility.UrlEncode(this._filepathlocal)); sb.Append("\"");
			sb.Append(",FilePathRemote:\""); sb.Append(HttpUtility.UrlEncode(this._filepathremote)); sb.Append("\"");
			sb.Append(",FileMd5:\""); sb.Append(this._filemd5); sb.Append("\"");
			sb.Append(",FileLength:\""); sb.Append(this._filelength); sb.Append("\"");
			sb.Append(",FileSize:\""); sb.Append(this._filesize); sb.Append("\"");
			sb.Append(",FilePos:\""); sb.Append(this._filepos); sb.Append("\"");
			sb.Append(",PostedLength:\""); sb.Append(this._postedlength); sb.Append("\"");
			sb.Append(",PostedPercent:\""); sb.Append(this._postedpercent); sb.Append("\"");
			sb.Append(",PostComplete:\""); sb.Append(this._postcomplete); sb.Append("\"");
			sb.Append(",PostedTime:\""); sb.Append(this._postedtime); sb.Append("\"");
			sb.Append("}]");
			return sb.ToString();
		}

		/// <summary>
		/// fid
		/// </summary>		
		private int _fid = 0;
		public int fid
		{
			get { return _fid; }
			set { _fid = value; }
		}
		/// <summary>
		/// 用户ID。与第三方系统整合使用。
		/// </summary>		
		private int _uid = 0;
		public int uid
		{
			get { return _uid; }
			set { _uid = value; }
		}
		/// <summary>
		/// 文件在本地电脑中的名称。
		/// </summary>		
		private string _filenamelocal = string.Empty;
		public string FileNameLocal
		{
			get { return _filenamelocal; }
			set { _filenamelocal = value; }
		}
		/// <summary>
		/// 文件在服务器中的名称。
		/// </summary>		
		private string _filenameremote = string.Empty;
		public string FileNameRemote
		{
			get { return _filenameremote; }
			set { _filenameremote = value; }
		}
		/// <summary>
		/// 文件在本地电脑中的完整路径。示例：D:\Soft\QQ2012.exe
		/// </summary>		
		private string _filepathlocal;
		public string FilePathLocal
		{
			get { return _filepathlocal; }
			set { _filepathlocal = value; }
		}
		/// <summary>
		/// 文件在服务器中的完整路径。示例：F:\ftp\uer\md5.exe
		/// </summary>		
		private string _filepathremote;
		public string FilePathRemote
		{
			get { return _filepathremote; }
			set { _filepathremote = value; }
		}
		/// <summary>
		/// 文件在服务器中的相对路径。示例：/www/web/upload/md5.exe
		/// </summary>		
		private string _filepathrelative = string.Empty;
		public string FilePathRelative
		{
			get { return _filepathrelative; }
			set { _filepathrelative = value; }
		}
		/// <summary>
		/// 文件MD5
		/// </summary>		
		private string _filemd5;
		public string FileMD5
		{
			get { return _filemd5; }
			set { _filemd5 = value; }
		}
		/// <summary>
		/// 文件总大小。以字节为单位
		/// 文件大小可能超过2G，所以使用long
		/// </summary>		
		private long _filelength;
		public long FileLength
		{
			get { return _filelength; }
			set { _filelength = value; }
		}
		/// <summary>
		/// 格式化的文件尺寸。示例：10.03MB
		/// </summary>		
		private string _filesize = string.Empty;
		public string FileSize
		{
			get { return _filesize; }
			set { _filesize = value; }
		}
		/// <summary>
		/// 文件续传位置。
		/// 文件大小可能超过2G，所以使用long
		/// </summary>		
		private long _filepos = 0;
		public long FilePos
		{
			get { return _filepos; }
			set { _filepos = value; }
		}
		/// <summary>
		/// 已上传大小。以字节为单位
		/// 文件大小可能超过2G，所以使用long
		/// </summary>		
		private long _postedlength = 0;
		public long PostedLength
		{
			get { return _postedlength; }
			set { _postedlength = value; }
		}
		/// <summary>
		/// 已上传百分比。示例：10%
		/// </summary>		
		private string _postedpercent = "0%";
		public string PostedPercent
		{
			get { return _postedpercent; }
			set { _postedpercent = value; }
		}
		/// <summary>
		/// PostComplete
		/// </summary>		
		private bool _postcomplete = false;
		public bool PostComplete
		{
			get { return _postcomplete; }
			set { _postcomplete = value; }
		}
		/// <summary>
		/// PostedTime
		/// </summary>		
		private DateTime _postedtime = DateTime.Now;
		public DateTime PostedTime
		{
			get { return _postedtime; }
			set { _postedtime = value; }
		}
		/// <summary>
		/// IsDeleted
		/// </summary>		
		private bool _isdeleted = false;
		public bool IsDeleted
		{
			get { return _isdeleted; }
			set { _isdeleted = value; }
		}
	}
}
